import serve from './../Base/Http.js'
import qs from 'qs'
// 数据列表
export default {
    discount(allPages) {
        console.log(allPages)
        return serve({
            method: 'get',
            params: {
                _gp: "admin.coupon",
                _mt: "queryCouponByTitle",
                // 优惠券
                title: allPages.value,
                type: allPages.dataType,
                status: allPages.status,
               //分页
                level: allPages.searchlevel,
                gender: allPages.searchgender,
                status: allPages.status,
                id: allPages.input,
                nickname: allPages.value,
                pageNo: allPages.currentPage,
                limit: allPages.eachpage
            }
        })
    },
    // sup树
    spuTitles() {
        return serve({
            method: 'get',
            params: {
                _gp: "admin.category",
                _mt: "categoryTree",
            }
        })
    },
    //编辑
    compile(ruleForm) {
        return serve({
            method: 'post',
            data: qs.stringify({
                _gp: "admin.coupon",
                _mt: "updateCoupon",
                id:ruleForm.id,
                title:ruleForm.title,
                type:ruleForm.type,
                status:ruleForm.status,
                description:ruleForm.description,
                limit:ruleForm.limit,
                discount:ruleForm.discount,
                min:ruleForm.min,
                total: ruleForm.total,
                surplus:ruleForm.surplus
            })
        })
    },

    // 添加
    addition(ruleForm) {
        console.log(ruleForm.gmtStart,ruleForm.gmtEnd)
        return serve({
            method: 'post',
            data: qs.stringify({
                _gp: "admin.coupon",
                _mt: "addCoupon",
                title:ruleForm.title,
                type:ruleForm.type,
                status:ruleForm.status,
                description:ruleForm.description,
                limit:ruleForm.limit,
                discount:ruleForm.discount,
                min:ruleForm.min,
                total:ruleForm.total,
                // gmtStart:ruleForm.gmtStart[0],
                // gmtEnd:ruleForm.gmtStart[1],    
            })
        })
    },
    //删除
    handleDeletec(data) {
        console.log(data)
        return serve({
            method: 'post',
            data: qs.stringify(
                {
                    _gp: "admin.coupon",
                    _mt: "deleteCoupon",
                    ...data
                }
            )
        })
    },
    //冻结
    status(row) {
        return serve({
            method: 'post',
            data: qs.stringify({
                _gp: "admin.coupon",
                _mt: "updateCouponStatus",
                id: row.id,
                status: row.status //状态
            })
        })
    },
}